package cur.nature.component.rocketmq.controller;

import cur.nature.component.rocketmq.message.MQSender;
import cur.nature.framework.core.log.LOG;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "RocketMQ 服务接口")
@RestController
@RequestMapping("component/rocketmq/v1/api")
@ConditionalOnProperty( value = {"cur.component.rocketmq.controller.enable"})
public class Component_RocketMQController {

    @Autowired
    private MQSender producerService;

    @Operation(summary = "本地测试接口")
    @GetMapping("/sendMessage")
    public String test() {
        LOG.info("sendMessage : " );
        // 发送消息
        producerService.sendSyncMessage("my-topic","Hello, RocketMQ..!");
        return "1";
    }

}